<!DOCTYPE html>
<%@page import="wt.fc.PersistenceHelper"%>
<%@page import="wt.fc.QueryResult"%>
<%@page import="wt.workflow.engine.WfActivity"%>
<%@page import="wt.workflow.work.WfAssignedActivity"%>
<%@page import="wt.fc.Persistable"%>
<%@page import="wt.org.WTPrincipal"%>
<%@page import="wt.org.WTUser"%>
<%@page import="wt.doc.WTDocument"%>
<%@page import="wt.session.SessionHelper"%>
<%@page import="wt.fc.ReferenceFactory"%><html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="shmged.com.shlcm.utils.*"%>
<%@ page import="java.util.*" %>
<%@page import="wt.httpgw.URLFactory,wt.query.QuerySpec,wt.workflow.work.WorkItem"%>
<head>
</head>
<%

String baseUrl = new URLFactory().getBaseHREF();


%>


<body>
<center>

	<div style="margin:10px 0;"></div>
	<div class="easyui-layout" style="width:450px;height:250px;">
		<div data-options="region:'center',title:'我的任务',iconCls:''"> 
		<div style="margin:10px 0;"></div>
		<div style="margin-left:50px"><b>未完成任务</b></div>
		<div style="margin:10px 0;"></div>
		<table id="workItemsRunningTable" style="height:100px"></table>
		<div style="margin:10px 0;"></div>
		<div style="margin-left:50px"><b>已完成任务</b></div>
		<div style="margin:10px 0;"></div>
		<table id="workItemsCloseTable"></table>
		</div>
	</div>
</center>
<script>
workItemsRunningTable();
workItemsCloseTable();
function workItemsRunningTable(){
	var url='<%=baseUrl%>shmged/jsp/com/shlcm/workflow/jspGetMyWorkItem.jsp';
	  $('#workItemsRunningTable').datagrid({   
	      url:url,
	      queryParams:{workState:"正在运行"},
	      nowrap:false,
	      loadMsg:'正在加载数据，请稍等。。。',
		  fitColumns: true,
	      columns:[[   
			  {field:'id',title:'id',width:20,checkbox:true},
			  {field:'itemImg',title:'',width:15},  
			  {field:'waName',title:'名称',width:30,  //添加超级链 
                  formatter:function(value,rowData,rowIndex){
					if(rowData.number!=""){
              		 return "<a href='javaScript:void(0)' onclick=\"javaScript:completeWorkInNewWindoow('"+rowData.id+"')\">"+rowData.waName+"</a>";  
	          		}
			  }
		          }, 
			  {field:'docImg',title:'',width:15}, 
			  {field:'doc',title:'主题',width:150,
				  formatter:function(value,rowData,rowIndex){
					if(rowData.number!=""){
            		 return "<a href='javaScript:void(0)' onclick=\"javaScript:subWorkItem('"+rowData.id+"')\">"+rowData.doc+"</a>";  
	          		}
			  }
		          },  
			  {field:'state',title:'状态',width:50}, 
			  {field:'zk',title:'状况',width:50}, 
			  {field:'modfTime',title:'最后更新时间',width:100}
	      ]] 
	    }); 
}

function workItemsCloseTable(){
	var url='<%=baseUrl%>shmged/jsp/com/shlcm/workflow/jspGetMyWorkItem.jsp';
	  $('#workItemsCloseTable').datagrid({   
	      url:url,
	      queryParams:{workState:"已执行"},
	      nowrap:false,
	      loadMsg:'正在加载数据，请稍等。。。',
		  fitColumns: true,
	      columns:[[   
			  {field:'id',title:'id',width:20,checkbox:true},
			  {field:'itemImg',title:'',width:15},  
			  {field:'waName',title:'名称',width:30,  //添加超级链 
                  formatter:function(value,rowData,rowIndex){
					if(rowData.number!=""){
              		 return "<a href='javaScript:void(0)' onclick=\"javaScript:completeWorkInNewWindoow('"+rowData.id+"')\">"+rowData.waName+"</a>";  
	          		}
			  }
		          }, 
			  {field:'docImg',title:'',width:15}, 
			  {field:'doc',title:'主题',width:150,
				  formatter:function(value,rowData,rowIndex){
					if(rowData.number!=""){
            		 return "<a href='javaScript:void(0)' onclick=\"javaScript:subWorkItem('"+rowData.id+"')\">"+rowData.doc+"</a>";  
	          		}
			  }
		          },  
			  {field:'state',title:'状态',width:50}, 
			  {field:'zk',title:'状况',width:50}, 
			  {field:'modfTime',title:'最后更新时间',width:100}
	      ]] 
	    }); 
}

function completeWorkInNewWindoow(oid){
	window.open(pageBaseUrl+"shmged/jsp/com/shlcm/workflow/setparticipant/tpTaskService.jsp?oid="+oid);
}

function commitWorkItem(id)
{
	addworkItemTab("","",id);
	
}

function subWorkItem(id)
{
	addworkItemPBOTab("","",id);
	
}

function addworkItemTab(tabObj,tabId,oid){
	var defaultTabId = "cmTabs";
	if(tabId){
		defaultTabId = tabId;
	}
	var tabDefault = {
		href:pageBaseUrl+"shmged/jsp/com/shlcm/workflow/setparticipant/tpTaskService.jsp?oid="+oid,
		title:"流程审批",
		selected: true,
		closable:true
	};
	var options ;
	if(tabObj){
	    var empty = {};
		options = $.extend(empty,tabDefault,tabObj);
	}else{
		options = tabDefault;
	}
	if($('#'+defaultTabId).tabs("exists",options.title)){
		$('#'+defaultTabId).tabs('select',options.title);
	}else{
	    $('#'+defaultTabId).tabs('add',options);
	}
}



function addworkItemPBOTab(tabObj,tabId,oid){
	var defaultTabId = "cmTabs";
	if(tabId){
		defaultTabId = tabId;
	}
	var tabDefault = {
		href:pageBaseUrl+"shmged/jsp/com/shlcm/workflow/workItem.jsp?oid="+oid,
		title:"流程信息",
		selected: true,
		closable:true
	};
	var options ;
	if(tabObj){
	    var empty = {};
		options = $.extend(empty,tabDefault,tabObj);
	}else{
		options = tabDefault;
	}
	if($('#'+defaultTabId).tabs("exists",options.title)){
		$('#'+defaultTabId).tabs('select',options.title);
	}else{
	    $('#'+defaultTabId).tabs('add',options);
	}
}
</script>
</body>
</html>